/***********************************************************************
 * Module:  DrugDose.java
 * Author:  Vanil
 * Purpose: Defines the Class DrugDose
 ***********************************************************************/
package hosp;

import db.dao.DrugDoseDao;
import db.dao.DrugsDao;
import db.dto.DrugDoseDto;
import db.dto.DrugsDto;
import db.exceptions.DrugDoseDaoException;
import db.exceptions.DrugsDaoException;
import db.factory.DrugDoseDaoFactory;
import db.factory.DrugsDaoFactory;

public class DrugDose {
   private DrugDoseDto dto;
    private DrugDoseDao dao;

    public DrugDose(DrugDoseDto dto) {
        this.dto = dto;
        dao = DrugDoseDaoFactory.create();
    }

    public DrugDoseDto getDto() {
        return dto;
    }

    public void setComment(String comment) {
        this.dto.setComment(comment);
    }

    public void setDrugs(DrugsDto drugs) {
        this.dto.setIdDrug(drugs.getIdDrug());
    }

    public void setIdDrugDose(int idDrugDose) {
        this.dto.setIdDrugdose(idDrugDose);
    }

    public void setTerm(long term) {
        dto.setTerm(term);
    }

    public void setWeigth(float weigth) {
        dto.setWeigth(weigth);
    }

    public void setPeriod(long period) {
        dto.setPeriod(period);
    }

    public int getIdDrugDose() {

        return dto.getIdDrug();
    }

    public long getPeriod() {
        return dto.getPeriod();
    }

    public long getTerm() {
        return dto.getTerm();
    }

    public double getWeigth() {
        return dto.getWeigth();
    }

    public DrugsDto getDrugs() throws DrugsDaoException {
        DrugsDao dao = DrugsDaoFactory.create();
        return dao.findByPrimaryKey(dto.getIdDrug());
    }

    public String getComment() {
        return dto.getComment();
    }
    public void updateUpload() throws DrugDoseDaoException {
        dao.update(dto.getIdDrugdose(),dto);
    }


}